#!../bin/birthstone
###############################################################################
#   Copyright (C) 2010 by Robert Tolliver                                     #
#   Robb.Tolli@gmail.com                                                      #
#                                                                             #
#   This file is part of Birthstone.                                          #
#                                                                             #
#   Birthstone is free software: you can redistribute it and/or modify        #
#   it under the terms of the GNU General Public License as published by      #
#   the Free Software Foundation, either version 3 of the License, or         #
#  (at your option) any later version.                                        #
#                                                                             #
#   Birthstone is distributed in the hope that it will be useful,             #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of            #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
#   GNU General Public License for more details.                              #
#                                                                             #
#   You should have received a copy of the GNU General Public License         #
#   along with Birthstone.  If not, see <http://www.gnu.org/licenses/>.       #
###############################################################################

# pause function for pausing between requirements.
def pause()
{
	write "Press Enter to continue..";
	read x;
}


# Requirements 1 and 2
print "Requirement 1 (shall): variables and literals";
print "and Requirement 2 (shall): output (print command)";


s := "hello";
n := 1.23;
b := true;
print "variable: " + s +   "  literal: hello";
print "variable: " + n +  "   literal: " + 1.23;
print "variable: " + b +  "   literal: " + true;

pause();


# Requirement 3
print "\n\nRequirement 3 (shall): input (read command)";

write "enter a string: ";
read str;
print 'you entered: "' + str + '"';

num := 0;
write "enter a number: ";
read num;
print 'you entered: ' + num;

pause();


# Requirement 4
print "\n\nRequirement 4 (shall): if/elif/else";
if (true)
{
  print "1 inside  if  of if(true),  else       TEST PASSED";
}
else
{
  print "2 inside else of if(true),  else       TEST FAILED";
}

if (false)
{
  print "3 inside  if  of if(false), elif(true) TEST FAILED";
}
elif (true)
{
  print "4 inside elif of if(false), elif(true) TEST PASSED";
}

pause();


# Requirement 5
print "\n\nRequirement 5 (shall): loop(s)";
#print "do-while loop: numbers 1-10 should be printed";
#i:=1;
# do
# {
# 	write " " + i;
# 	i = i + 1;
# } while (i <= 10);
# print;
print "while loop: numbers 1-10 should be printed";
i := 0;
while (i < 10)
{
	i = i + 1;
 	write " " + i;
}
print;
print "for loop: numbers 1-10 should be printed";
for(i = 1; i <= 10; ++i)
	write " " + i;
print;

pause();


# Requirement 6
print "\n\nRequirement 6: arithmatic operators";
x := 0;
y := 0;
write "enter x: ";
read x;
write "enter y: ";
read y;

print "x + y = " + (x + y);
print "x - y = " + (x - y);
print "x * y = " + (x * y);
print "x / y = " + (x / y);

pause();


# Requirement 7
print "\n\nRequirement 7 (shall): order of operations";
print "1 + 2 * 3 = " + (1 + 2 * 3);
print "1 - 3 / 2 = " + (1 - 3 / 2);
print "2 * 3 - 4 = " + (2 * 3 - 4);

pause();


# Requirement 8
print "\n\nRequirement 8 (shall): parenthesis";

print "1 * (2 + 3) = " + (1 * (2 + 3));
print "1 - (2 * (3 - 4)) = " + (1 - (2 * (3 - 4)));

pause();


# Requirement 9
print "\n\nRequirement 9 (shall): string appending and concatenation";
A := "aa";
B := "bb";
print 'A = "aa", B = "bb"';

print 'A == "' + A + '"';
print 'A + B == "' + (A + B) + '"';
print 'A == "' + A + '"';
A += B;
print "A += B";
print 'A == "' + A + '"';

pause();


# Requirement 10
print "\n\nRequirement 10 (shall): and (&&), or(||), and not(!) operators";
if (true && true)   print 'true  && true  TEST PASSED';
if (true || true)   print 'true  || true  TEST PASSED';
if (false && false) print 'false && false TEST FAILED';
if (false || false) print 'false || false TEST FAILED';
if (true && false)  print 'true  && false TEST FAILED';
if (true || false)  print 'true  || false TEST PASSED';
if (!true)          print '!true          TEST FAILED';
if (!false)         print '!false         TEST PASSED';

pause();


# Requirement 11
print "\n\nRequirement 11 (shall): Comparison operators (numbers and strings)";

if ("aa" <  "ab") print '"aa" <  "ab" TEST PASSED';
if ("aa" <= "ab") print '"aa" <= "ab" TEST PASSED';
if ("aa" == "ab") print '"aa" == "ab" TEST FAILED';
if ("aa" >= "ab") print '"aa" >= "ab" TEST FAILED';
if ("aa" >  "ab") print '"aa" >  "ab" TEST FAILED';
if ("aa" != "ab") print '"aa" != "ab" TEST PASSED';
print;

if ("aa" <  "aa") print '"aa" <  "aa" TEST FAILED';
if ("aa" <= "aa") print '"aa" <= "aa" TEST PASSED';
if ("aa" == "aa") print '"aa" == "aa" TEST PASSED';
if ("aa" >= "aa") print '"aa" >= "aa" TEST PASSED';
if ("aa" >  "aa") print '"aa" >  "aa" TEST FAILED';
if ("aa" != "aa") print '"aa" != "aa" TEST FAILED';
print;

if (1.5 <  -2) print '1.5 <  -2 TEST FAILED';
if (1.5 <= -2) print '1.5 <= -2 TEST FAILED';
if (1.5 == -2) print '1.5 == -2 TEST FAILED';
if (1.5 >= -2) print '1.5 >= -2 TEST PASSED';
if (1.5 >  -2) print '1.5 >  -2 TEST PASSED';
if (1.5 != -2) print '1.5 != -2 TEST PASSED';
print;

if (1.5 <  1.5) print '1.5 <  1.5 TEST FAILED';
if (1.5 <= 1.5) print '1.5 <= 1.5 TEST PASSED';
if (1.5 == 1.5) print '1.5 == 1.5 TEST PASSED';
if (1.5 >= 1.5) print '1.5 >= 1.5 TEST PASSED';
if (1.5 >  1.5) print '1.5 >  1.5 TEST FAILED';
if (1.5 != 1.5) print '1.5 != 1.5 TEST FAILED';
print;

pause();
# Requirement 12
print "\n\nRequirement 12 (shall): Comparison operators (booleans)";
if (true  == true)  print 'true  == true  TEST PASSED';
if (true  != true)  print 'true  != true  TEST FAILED';
if (false == false) print 'false == false TEST PASSED';
if (false != false) print 'false != false TEST FAILED';
if (true  == false) print 'true  == false TEST FAILED';
if (true  != false) print 'true  != false TEST PASSED';
print;

pause();
# Requirement 13
print "\n\nRequirement 13 (will): List Variables";
list := ['hello', 1.23, true];
print list;

pause();
# Requirement 14
print "\n\nRequirement 14 (will): Functions";
def func()
{
	print "running a function..";
}

print "calling a function..";
func();
